//
//  LBAVPlayerView
//  app
//
//  Created by 刘文扬 on 2018/3/26.
//
//

#import "LBAVPlayerView.h"
#import <ZFPlayer.h>
#import "LBAVPlayerControlView.h"

@interface LBAVPlayerView ()<ZFPlayerDelegate,ZFPlayerControlViewDelagate>

/** ZFPlayerView*/
@property(nonatomic,strong)ZFPlayerView *playerView;

@end

@implementation LBAVPlayerView



#pragma mark - life cycle

-(instancetype)init
{
    self = [super init];
    if (self) {
        [self initSubviews];
    }
    return self;
}


#pragma mark - model event

#pragma mark - view event

#pragma mark - public

#pragma mark - getter / setter

-(ZFPlayerView *)playerView
{
    if (_playerView == nil) {
        
        _playerView = [[ZFPlayerView alloc] init];
        _playerView.hasPreviewView = NO;
        _playerView.forcePortrait = YES;
    }
    return _playerView;
}

#pragma mark - private

-(void)initSubviews
{
    [self addSubview:self.playerView];
    [self.playerView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.insets(UIEdgeInsetsZero);
    }];
    // control view（you can custom）
    LBAVPlayerControlView *controlView = [[LBAVPlayerControlView alloc] init];
    // model
    
    //隐藏按钮
//    UIButton *button = [controlView valueForKey:@"backBtn"];
//    button.hidden = YES;
    
    ZFPlayerModel *playerModel = [[ZFPlayerModel alloc]init];
    playerModel.fatherView = self;
    playerModel.videoURL = [NSURL URLWithString:@"http://1254291217.vod2.myqcloud.com/76af0f21vodgzp1254291217/11c253b27447398155150797281/f0.mp4"];
//    playerModel.title = @"回播";
    playerModel.placeholderImage = nil;
    [self.playerView playerControlView:controlView playerModel:playerModel];
    
    // delegate
    self.playerView.delegate = self;
    // auto play the video
    [self.playerView autoPlayTheVideo];
}

#pragma mark - delegate

#pragma mark - other
@end
